package com.example.jetpacktest.activity.material_design

import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import com.example.jetpacktest.R
import com.google.android.material.snackbar.Snackbar

class ToolBarTest001: AppCompatActivity() {

    private lateinit var mToolBar: Toolbar

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_toolbar_test001)
        mToolBar = findViewById(R.id.toolbar)
        mToolBar.setNavigationOnClickListener {
            Toast.makeText(this, "点击了导航按钮", Toast.LENGTH_SHORT).show()
        }
        mToolBar.setOnMenuItemClickListener { menuItem ->
            when(menuItem.itemId){
                R.id.menu_1 -> run{
                    Toast.makeText(this, "点击了menu....1 ", Toast.LENGTH_SHORT).show()
                    true
                }
                R.id.menu_2 -> run{
                    Toast.makeText(this, "点击了menu...2 ", Toast.LENGTH_SHORT).show()
                    true
                }
                R.id.menu_3 -> run{
                    Toast.makeText(this, "点击了menu...3 ", Toast.LENGTH_SHORT).show()
                    true
                }
                else -> false
            }
        }
    }

}